<!DOCTYPE html>
<html>
<?php $this->load->view('admin/public/header.html');?>
<style>
	. space{padding:10px;}

</style>
<body class="childrenBody">
<form class="layui-form layui-row layui-col-space20" lay-filter="expert_form">
	<div class="layui-col-md6 layui-col-xs12 ">
		<div class="layui-row ">
			<div class="layui-col-md12 layui-col-xs7">
				
				<div class="layui-form-item magt3">
					<div class="layui-row layui-col-space10">
						<div class="layui-col-md6 layui-col-xs6">
							<label class="layui-form-label">公司LOGO</label>
							<div class="layui-upload-list thumbBox posterBox mag0 magt3">
								<img class="layui-upload-img thumbImg posterimg"  src="<?php echo  NULL!==$company['logo']?IMAGEHOST.$company['logo']:''?>">
								<input type="hidden" class="poster" name="logo" value="<?php echo @$company['logo']?>">
							</div>
						</div>						
					</div>
				</div>
							
				<div class="layui-form-item magt3">
					<label class="layui-form-label">公司名称</label>
					<div class="layui-input-block">
						<input type="hidden" name="companyId" value="<?php echo @$company['companyId']?>">
						<input type="hidden" name="userId" value="<?php echo $this->session->userdata('sellerId')?>">
						<input type="text" class="layui-input name" name="name" value="<?php echo @$company['name']?>" lay-verify="required"  >
					</div>
				</div>
				
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">联系方式</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" lay-verify="required" name="phone"  value="<?php echo @$company['phone']?>"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">房间数</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" lay-verify="required" name="roomNum"  value="<?php echo @$company['roomNum']?>"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">床位数</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" lay-verify="required" name="bedNum"  value="<?php echo @$company['bedNum']?>"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">老板姓名</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" lay-verify="required" name="bossName"  value="<?php echo @$company['bossName']?>"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">经理姓名</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" lay-verify="required" name="managerName"  value="<?php echo @$company['managerName']?>"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">人均收入</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" lay-verify="required" name="incomeAvg"  value="<?php echo @$company['incomeAvg']?>"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">平均客流量</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" lay-verify="required" name="flux"  value="<?php echo @$company['flux']?>"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">人均消费</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" lay-verify="required" name="price"  value="<?php echo @$company['price']?>"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">会员保有量</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" lay-verify="required" name="memberNum"  value="<?php echo @$company['memberNum']?>"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">公司详情</label>
					<div class="layui-input-block">
						<textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="content"><?php echo @$company['content']?></textarea>
					</div>
				</div>
				
				
			</div>
		</div>
		
	</div>
	
	<div class="layui-col-md6 layui-col-xs12 ">
		<div class="layui-row ">
			<div class="layui-col-md12 layui-col-xs7">
				
				
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">平均消费</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" lay-verify="required" name="consume"  value="<?php echo @$company['consume']?>"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">所属行业</label>
					<div class="layui-input-block">
						<select name="tradeId" required lay-search>
						  <option value="">请选择分类</option>
						  <?php foreach($trade as $key=>$val):?>
						  	<option value="<?php echo $val['typeId']?>" <?php if($val['typeId']==@$company['tradeId']) echo 'selected' ?> ><?php echo $val['typeName']?> </option>
						  <?php endforeach;?>
						</select>
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">提供的服务</label>
					<div class="layui-input-block">
						<?php foreach($service as $key=>$val):?>
							<input type="checkbox" name="serviceTypeIds[]" class="tags" <?php if(in_array($val['typeId'],@$company['serviceTypeIds'])) echo 'checked' ?>  lay-verify="required" title="<?php echo $val['typeName']?>" value="<?php echo $val['typeId']?>">
						<?php endforeach;?>
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">公司地址</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" name="address"  value="<?php echo @$company['address']?>" lay-verify="required"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">公司简介</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" name="brief"  value="<?php echo @$company['brief']?>" lay-verify="required"  >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">审核状态</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" disabled
							 value="<?php
							 		 if(@$company['issue']==0){
							 			echo '审核中';
							 		 }elseif(@$company['issue']==1){
							 		 	echo '审核通过';
							 		 }elseif(@$company['issue']==2){
							 		 	echo '审核未通过';
							 		 } ?> " 
						>
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">地理位置</label>
					<input type="hidden" name="lat" value="<?php echo @$company['lat']?>" />
					<input type="hidden" name="lng" value="<?php echo @$company['lng']?>" />
					<div class="layui-input-block">
						<input type="text" class="layui-input name" id="localcity" style="width:85%;display:inline-block"  placeholder="您可输入城市进行查询"  >
						<a class="layui-btn " style="float:right" id="get_localcity">定位</a>
					</div>
					<br>
					<div class="layui-input-block">
						<div id="container" style="height:300px"></div>
					</div>
				</div>
				
				<?php if(isset($adminFlag)&&$adminFlag==1):?>
					<!-- 后台管理员显示的内容 -->
					<div class="layui-form-item magt3">
						<label class="layui-form-label">技师数量</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input name"  value="<?php echo @$company['technicianNum']?>"  >
						</div>
					</div>
					<div class="layui-form-item magt3">
						<label class="layui-form-label">注册时间</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input name"   value="<?php echo date('Y-m-d',@$company['createTime'])?>"   >
						</div>
					</div>
				<?php else:?>	
				
					<div class="layui-right">
						<a class="layui-btn layui-btn-sm" lay-filter="save" lay-submit><i class="layui-icon">&#xe609;</i>保存</a>
					</div>
				<?php endif;?>
			</div>
		</div>
		
	</div>
	
</form>
<script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp&key=AFOBZ-KKU6D-SKM4E-PCLYK-D6ICO-KZBFD"></script>

<script type="text/javascript">

layui.use(['form','layer','layedit','upload'],function(){
	
    var form = layui.form
        layer =  layui.layer ,  
        layedit = layui.layedit,
        upload=layui.upload,
        $ = layui.jquery;
	
    var lat=$("[name=lat]").val();
    var lng=$("[name=lng]").val();
    if(lat&&lng){    	
    	var center=new qq.maps.LatLng(lat,lng);
    }else{
    	var center=new qq.maps.LatLng(39.916527,116.397128);
    }
    
    var map = new qq.maps.Map(document.getElementById("container"), {
        // 地图的中心地理坐标。
        center: center,
        zoom:10
    });
    
    var marker = new qq.maps.Marker({
        position: center,
        map: map
    });
    var listener = qq.maps.event.addListener(
    		map,
    	    'click',
    	    function(e) {    			
    	        var local=new qq.maps.LatLng(e.latLng.getLat(),e.latLng.getLng())
    	        
    	        marker.setPosition(local);   
    	        $("[name=lat]").val(e.latLng.getLat());		//纬度
    	        $("[name=lng]").val(e.latLng.getLng());		//经度
    	    }
    	);
    
    
    $('#get_localcity').click(function(){
    	citylocation = new qq.maps.CityService({
            complete : function(results){
                map.setCenter(results.detail.latLng);
                marker.setPosition(results.detail.latLng);   
               var pos=results.detail.latLng;
               $("[name=lat]").val(pos.lat);		//纬度
   	           $("[name=lng]").val(pos.lng);		//经度
            }
        });
    	
    	var localcity = document.getElementById("localcity").value;
        citylocation.searchCityByName(localcity);
    })
    
  //上传缩略图
    upload.render({
        elem: '.posterBox',
        //multiple:true,
        url: '<?php echo site_url("upload/upload")?>',
        before: function(obj){ //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
        	layerindex=layer.load(); //上传loading
        },
        done: function(res, index, upload){
        	layer.close(layerindex);
            if(res.code==200){
            	layer.msg('上传成功');
            	var url=res.content.url
            	var src='<?php echo IMAGEHOST?>'+url;
            	$('.posterimg').attr('src',src);
                $('.thumbBox').css("background","#fff"); 
                $(".poster").val(url);
            }else{
            	layer.msg('上传失败');
            }
        }
    });
    
    form.on("submit(save)",function(data){
		var tempcontent=layedit.getContent(editIndex);
    	
    	data.field.content=tempcontent;
        var index = layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        
        $.ajax({
        	type:'post',
        	data:data.field,
        	url:'<?php echo site_url("seller/company/save")?>',
        	dataType: "json", 
        	success:function(res){
        		//console.log(res.code);return;
        		if(res.code==200){
        			layer.close(index);
                    layer.msg("操作成功！");                    
                    
        		}else{
        			layer.close(index);
                    layer.msg("操作失败！");
        		}
        	},
        	fail:function(){
        		layer.close(index);
                layer.msg("操作失败！");
        	}
        })        
        
    })

  //创建一个编辑器
    var editIndex = layedit.build('content',{
        height : 535,
        uploadImage : {
            url : "<?php echo site_url('upload/editUpload')?>"
        }
    });
	
})
</script>
</body>
</html>